//package com.zws.cucumber.optimization.socket.connector;
//
//import com.zws.cucumber.optimization.thread.ZwsCallerExecutionJettyThreadPool;
//import com.zws.cucumber.optimization.thread.ZwsSuspendedException;
//import org.eclipse.jetty.io.ByteBufferPool;
//import org.eclipse.jetty.server.ConnectionFactory;
//import org.eclipse.jetty.server.HttpConnectionFactory;
//import org.eclipse.jetty.server.LocalConnector;
//import org.eclipse.jetty.server.Server;
//import org.eclipse.jetty.util.ssl.SslContextFactory;
//import org.eclipse.jetty.util.thread.Scheduler;
//
//import java.io.IOException;
//import java.util.concurrent.Executor;
//
//public final class ZwsCallerExecutionJettyConnector extends LocalConnector {
//
//    public static final ZwsSuspendedException SUSPENDED_EXCEPTION = new ZwsSuspendedException();
//
//    private static ZwsCallerExecutionJettyThreadPool threadPool = new ZwsCallerExecutionJettyThreadPool();
//    public boolean isInvoking = false;
//
//    public ZwsCallerExecutionJettyConnector(Server server, Executor executor, Scheduler scheduler, ByteBufferPool pool, int acceptors, ConnectionFactory... factories) {
//        super(server, executor, scheduler, pool, acceptors, factories);
//    }
//
//    public ZwsCallerExecutionJettyConnector(Server server) {
//        super(server, threadPool, null, null, 1, new HttpConnectionFactory());
//    }
//
//    public ZwsCallerExecutionJettyConnector(Server server, SslContextFactory sslContextFactory) {
//        super(server, sslContextFactory);
//    }
//
//    public ZwsCallerExecutionJettyConnector(Server server, ConnectionFactory connectionFactory) {
//        super(server, connectionFactory);
//    }
//
//    public ZwsCallerExecutionJettyConnector(Server server, ConnectionFactory connectionFactory, SslContextFactory sslContextFactory) {
//        super(server, connectionFactory, sslContextFactory);
//    }
//
//    public boolean isInvoking() {
//        return isInvoking;
//    }
//
//    public void setInvoking(boolean invoking) {
//        isInvoking = invoking;
//    }
//
//    @Override
//    protected void accept(int acceptorID) throws IOException, InterruptedException {
//        if (isInvoking()) {
//            setInvoking(false);
//            super.accept(acceptorID);
//        } else {
//            throw SUSPENDED_EXCEPTION;
//        }
//    }
//
//    @Override
//    protected boolean handleAcceptFailure(Throwable ex) {
//        if (ex == SUSPENDED_EXCEPTION) {
//            throw SUSPENDED_EXCEPTION;
//        }
//        return super.handleAcceptFailure(ex);
//    }
//
////    public Runnable getAcceptorRunnable() {
////        return threadPool.getLastRunnable();
////    }
//
//}
